﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Halcon二次开发.View.图片显示弹窗
{
    public partial class NgMessage : Form
    {
        static NgMessage instance;

        /// <summary>
        /// 单例模式
        /// </summary>
        /// <param name="obj">路径</param>
        /// <param name="okng">OK还是NG图片</param>
        /// <returns></returns>
        public static NgMessage GetSingle(string message)
        {
            if (instance == null)
            {
                instance = new NgMessage();
            }
            //窗体自动获得焦点
            instance.BringToFront();
            instance.Focus();
            instance.SetMessage(message);
            return instance;

        }
        public void SetMessage(string message)
        {
            try
            {
                label1.Text = message;
            }
            catch
            {
            }
        }
        public NgMessage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void NgMessage_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.Hide();
            e.Cancel = true;
        }
    }
}
